<%@ page language="java" pageEncoding="UTF-8"%>
<script>
$(function(){
	$('.icon-reload').click(
		function (){ 
			$('#wcTree').tree({url:'<%=request.getContextPath()%>/warehouse/getAllWareHouseClassJson.action'});
			$('#wcTree').tree('reload')
		}
	);
	$(".icon-reload").css("cursor","pointer");
		
		$('#wcTree').tree({
			animate: true,
			url: "<%=request.getContextPath()%>/warehouse/getAllWareHouseClassJson.action",
			onBeforeExpand:function(node){
				$('#wcTree').tree("options").url="<%=request.getContextPath()%>/warehouse/getAllWareHouseClassJson.action?wc.id=" + node.id;
			},
			onClick:function(node){
				var node = $('#wcTree').tree('getSelected');
				$('#wars').datagrid('reload',{wareClassId:node.id});
				$('#wcTree').tree('expand',node.target);
				$('#wareClassId').val(node.id);//点击商品类别的时候，将当前类别Id设置到查询表单中
			},
			onContextMenu: function(e, node){
				e.preventDefault();
				$('#wcTree').tree('select', node.target);
				$('#mm').menu('show', {
					left: e.pageX,
					top: e.pageY
				});
			}
			
		});
		$('#wars').datagrid({
				iconCls:'icon-save',
				nowrap: false,
				striped: true,
				collapsible:true,
				url:'<%=request.getContextPath()%>/warehouse/getWarsByWarClassJson.action',
				sortName: 'code',
				sortOrder: 'desc',
				remoteSort: false,
				idField:'code',
				singleSelect:true,
				columns:[[
					{field:'name',title:'名称',width:120},
					{field:'no',title:'编号',width:120}
				]],
				pageSize:10,  
                pageList:[5,10,15,20],  
                fitColumns: true,  
				pagination:true,
				rownumbers:true,
				onDblClickRow:function(){
					selectWareHouse();
				}
		});
		
		
		
		$('a[name=clearWareData]').click(function(){
			$('input[name=wareName]').val('');
		});
		
		$('a[name=queryWare]').click(function(){
			var wareClassId = $('#wareClassId').val();
			var wareName = $('#wareName').val();
			if(wareClassId == "" || wareClassId == null)
				$('#wars').datagrid('reload',{wareName:wareName});
			else
				$('#wars').datagrid('reload',{wareClassId:wareClassId, wareName:wareName});
		});
		
		$('#wareName').keydown(function(e){
		      if(e.keyCode==13) {
		    	  var wareName = $('#wareName').val();
		    	  $('#wars').datagrid('reload',{wareName:wareName});
		      }
		});
		
});
// 往来单位内容读取结束
</script>
<div id="wareHouseDlg" class="easyui-dialog" style="width:650px;height:380px;"  
        closed="true" buttons="#wh-dlg-buttons"> 
        <div class="easyui-layout" fit="true" style="background:#ccc;">
	        <div region="west" iconCls="icon-reload" title="仓库分类" split="true" style="width:180px;">
				<ul id="wcTree"></ul>
			</div>
			<div region="center" style="overflow:auto;">
				<!-- 条件查询table -->
				<table style="font-size:12px; background:#fafafa; padding:10px;" border="0">
					<input type="hidden" id="wareClassId" name="wareClassId" value="" />
					<tr>
						<td> 仓库名称
							<input type="text" id="wareName" name="wareName" class="easyui-validatebox"  value="${wareName}" />
						</td>
						<td>
							<a href="#" class="easyui-linkbutton" name="queryWare">查询</a>
			 				<a href="#" class="easyui-linkbutton" name="clearWareData">重置</a>
						</td>
					</tr>
				</table>
			
				<table id="wars"></table>
			</div> 
		</div>
		<div id="wh-dlg-buttons">  
		    <a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="selectWareHouse()">确认</a>  
		    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#wareHouseDlg').dialog('close')">取消</a>  
		</div> 
</div>